<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数组移出与新建</title>

</head>
<body>
    <script>
        var arr = [1,2,3,4,2,5,6,2,7,2];
          len = arr.length;
           resultArr1 = [];
           resultArr2 = [];
      for(var i=0; i<len; i++){
           var item1 = arr[i];
           flag = false;
          for(var j=0; j<len; j++){
          if(j == i) {
             continue;
        }
           var item2 = arr[j];
           if(item1 == item2){
               flag = false;
            resultArr2.push(item2);
                 break;
            }flag = true;
            }
            if(flag){
              resultArr1.push(item1);
            }
         }
        alert("原数组"+resultArr1 +"\n"+ "新数组" + resultArr2);
        console.log("原数组"+resultArr1 + "\n"+"新数组" + resultArr2);
    </script>
</body>
</html>